/*
 * @Desc:
 * @Version: v1.00
 * @Author: went
 * @Date: 2021-12-09 14:19:13
 * @LastEditors: went
 * @LastEditTime: 2022-10-24 10:23:30
 */
import jfRequest from "../../index";
import {
  Page,
  AddRota,
  SingleRota,
  EditRota,
  ListRota,
  AddRotaInfo,
} from "./types";
import { IResultType } from "types/request";

export function getRotaList(data: Page) {
  return jfRequest.post<IResultType<Page>>({
    url: "api/v1/rota/list",
    data,
  });
}

export function getRecordList(data: Page) {
  return jfRequest.post<IResultType<Page>>({
    url: "api/v1/rota/record/list",
    data,
  });
}

// 当天值班记录
export function getRecordToday(id: string) {
  return jfRequest.get<IResultType<Page>>({
    url: "/api/v1/rota/record/" + id,
  });
}

export function addRotaInfo(data: AddRota) {
  return jfRequest.post<IResultType<AddRota>>({
    url: "api/v1/rota",
    data,
  });
}

export function addRotaSingleInfo(id: string) {
  return jfRequest.get<IResultType<SingleRota>>({
    url: "api/v1/rota/" + id,
  });
}

export function editRota(data: EditRota) {
  return jfRequest.put<IResultType<EditRota>>({
    url: "api/v1/rota",
    data,
  });
}

export function addRota(data: AddRotaInfo) {
  return jfRequest.post<IResultType<AddRotaInfo>>({
    url: "api/v1/rota",
    data,
  });
}

export function exportRota(data: ListRota) {
  return jfRequest.get<IResultType<ListRota>>({
    url: "api/v1/rota/detail/export",
    data,
  });
}

export function importRota(id: string, data: any) {
  return jfRequest.post<IResultType<ListRota>>({
    url: "api/v1/rota/detail/import/" + id,
    data,
  });
}

export function exportRotaMoban() {
  return jfRequest.get<IResultType<null>>({
    url: "/api/v1/rota/detail/download/template",
  });
}

export function deleteRota(id: string) {
  return jfRequest.delete<IResultType<null>>({
    url: "api/v1/rota/" + id,
  });
}

export function deletePersonRota(id: string) {
  return jfRequest.delete<IResultType<null>>({
    url: "api/v1/rota/detail/person/" + id,
  });
}

export function detailListRota(data: ListRota) {
  return jfRequest.get<IResultType<ListRota>>({
    url: "api/v1/rota/detail/list",
    params: data,
  });
}

export function getTeacher() {
  return jfRequest.get<IResultType<ListRota>>({
    url: "api/v1/contacts/teacher/list",
  });
}
